<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/normalize.css">
    <style>
        
       
        .box {
            width:200px;
            height:200px;
            background-color:pink;
            border-radius: 10px;
            position: absolute;
            left:0;
            top:0;
        }
    </style>
</head>
<body>
    <div class="box" style="top:0;left:0">
        
    </div>
    <script>
        var x = 0;
        var y = 0;

    


        var box = document.querySelector(".box");
        box.ontouchstart = function (e){
            
            x = e.changedTouches[0].pageX - this.offsetLeft;
            y = e.changedTouches[0].pageY - this.offsetTop;

           
        }
        
        box.ontouchmove = function (e) {
       
            var left = e.targetTouches[0].pageX - x;
            var top = e.targetTouches[0].pageY - y;

            

            e.target.style.left = `${left}px`;
            e.target.style.top = `${top}px`;
            


        }

        box.ontouchend = function (e) {
            
           

        }


        box.ontouchcancel =function (e) {
            console.log(e.type,'<--touchcancel type');
            console.log('ontouchcancel');
        }

        

    </script>
</body>
</html>